import Mock from "mockjs";

//延时
Mock.setup({
  timeout: "500-1000",
});

//验证码接口
Mock.mock("/loginCode", (req) => {
  return {
    message: "获取验证码成功",
    code: 1,
    yzm: Math.random().toString().slice(-4),
  };
});

//登录接口
Mock.mock("/logins", "post", (req) => {
  const { username, password, code } = JSON.parse(req.body);
  console.log(username, password, code);
  if (
    username == "admin" &&
    password == 123456 &&
    code == localStorage.getItem("code")
  ) {
    return {
      message: "登录成功",
      code: 1,
      token: "ASDFGHHKLVXVVNNRIUY",
      userinfo: "小马",
    };
  } else {
    return {
      message: "账号密码不匹配",
      code: 0,
    };
  }
});

//车次数据
let data = Mock.mock({
    "data|10":[
        {
            "id|+1": 1,
            train: "G71",
            vehicle:"@cname(2,3)",
            "all|586-600": 586,
            carriage: 8,
            num: 646,
            date: "@datetime",
            "status|0-1": 1,
          }
    ]
})

//车站数据
let stationData = Mock.mock({
   "list|20":[
    {
      "id|1-2":1,
      "city|1":['合肥','南京站'],
      "status|0-1":0,
      "key|+1":0
    }
   ]
})

//线路数据
let lineData = Mock.mock({
  "list|20":[
    {
      "id|+1":1,
      train:['G71','高铁'],
       date: "@datetime",
       line:['北京西','昆明南','① 北京西 → ② 石家庄 → ③ 郑州东 →  ④ 武汉 → ⑤ 长沙南 →  ⑥怀化南 → ⑦贵阳北 → ⑧ 昆明南'],
      "status|0-1":0,
      "key|+1":0
    }
   ]
})

//车票数据
let ticketData = Mock.mock({
  "list|20":[
    {
      "id|+1":1,
       train:['G71','高铁'],
       date: "@date(yyyy-mm-dd)",
       line:['北京西','成都东'],
       depart:['07:05','14:16'],
       last:['10:24','当日到达'],
       seat:['软卧','硬卧','硬座','无座','商务座','一等座','二等座','60','128','220'],
       "type|0-1":0,
      "status|0-1":0,
      "key|+1":0
    }
   ]
})
//订单数据
let oredrData = Mock.mock({
  "list|20":[
    {
      "id|+1":1,
       msg:['E156789','1881234600','2022-10-10 12:20:39'],
       train:['G71','高铁'],
       line:['北京西','武汉'],
       depart:['07:05','14:16'],
       riding:['@cname(3)','@date(yyyy-mm-dd)'],
       seat:['￥120.0','08车02号','一等座'],
      "status|0-1":0,
      "key|+1":0,
      "children|20":[
        {
          "id|+1":1,
          "name":['G71','高铁']
        },
      ]
    }
   ]
})

//生成个人轨迹信息
Mock.mock('/getInfo',()=>{
  return {
    message: "获取轨迹列表成功",
    code: 1,
    // data: [
    //   {
    //     userId:1,
    //     head:'https://img1.baidu.com/it/u=3108300770,3645231302&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500',
    //     name:'小马',
    //     idCard:410726197704234411,
    //     date:'2022-10-10 形程',
    //       "list":[
    //         {
    //           start:'北京西',
    //           end:'武汉',
    //           type:'G',
    //           num:71,
    //           createTime:'2022-10-10 07:05',
    //           endTime:' 11:01',
    //           week:'周二',
    //           startType:'一等座',
    //           price:'190',
    //           seatLing:[116.378517,39.865246],
    //           endLing:[114.304569,30.593354],
    //           identity:'身份证',
    //           card:"410726**********11",
    //           carriage:'03车厢16A号'
    //         },
    //         {
    //           start:'河南',
    //           end:'上海',
    //           type:'G',
    //           num:2285,
    //           createTime:'2022-10-10 13:46',
    //           endTime:'2022-10-10 16:24',
    //           week:'周二',
    //           startType:'一等座',
    //           price:'246',
    //           seatLing:[113.753094,34.767052],
    //           endLing:[121.455708,31.249574],
    //           identity:'身份证',
    //           card:"410726**********11",
    //           carriage:'03车厢16A号'
    //         }
    //       ]
    //     }
    // ]
    data:[
      {
        "userid": "1001",
        "name": "小马",
        "id_number": "410726197704234411",
        "ticket_info": [
          {
            "id": "20230601G12340524",
            "start": "北京南站",
            "destination": "上海虹桥站",
            "createTime":'2022-10-10 13:46',
            "endTime":'2022-10-10 16:24',
            "train_number": "G1234",
            "carriage_number": 5,
            "seat_number": 24,
            "seat_class": "二等座",
            "price": 680,
            "start_latitude_longitude": [116.378, 39.865],
            "destination_latitude_longitude": [121.419, 31.204],
            "train_type": "高铁"
          },
          {
            "id": "20230601G23450612",
            "start": "北京西",
            "destination": "武汉",
            "createTime":'2022-10-10 07:05',
             "endTime":' 11:01',
            "train_number": "G2345",
            "carriage_number": 8,
            "seat_number": 28,
            "seat_class": "一等座",
            "price": 1200,
            "start_latitude_longitude":[116.378517,39.865246],
            "destination_latitude_longitude": [114.304569,30.593354],
            "train_type": "高铁"
          }
        ]
      },
      {
        "userid": "1002",
        "name": "张三",
        "id_number": "310101198702020202",
        "ticket_info": [
          {
            "id": "20230601D25090106",
            "start": "上海虹桥站",
            "destination": "南京南站",
            "createTime":'2022-10-10 07:05',
            "endTime":' 11:01',
            "train_number": "D2509",
            "carriage_number": 12,
            "seat_number": 5,
            "seat_class": "一等座",
            "price": 248,
            "start_latitude_longitude": [121.419, 31.204],
            "destination_latitude_longitude": [118.791, 32.041],
            "train_type": "动车"
          },
          {
            "id": "20230601G32475891",
            "start": "南京南站",
            "destination": "深圳北站",
            "createTime":'2022-10-10 12:46',
            "endTime":'2022-10-10 17:24',
            "train_number": "G3247",
            "carriage_number": 3,
            "seat_number": 17,
            "seat_class": "商务座",
            "price": 1780,
            "start_latitude_longitude": [118.791, 32.041],
            "destination_latitude_longitude": [114.029, 22.612],
            "train_type": "高铁"
          }
        ]
      },
      {
        "userid": "1003",
        "name": "麻五",
        "id_number": "440101198501030303",
        "ticket_info": [
          {
            "id": "20230601G78901234",
            "start": "广州南站",
            "destination": "长沙南站",
            "createTime":'2022-10-10 14:46',
            "endTime":'2022-10-10 17:24',
            "train_number": "G7890",
            "carriage_number": 6,
            "seat_number": 28,
            "seat_class": "二等座",
            "price": 235.5,
            "start_latitude_longitude": [113.321, 23.128],
            "destination_latitude_longitude": [112.983, 28.156],
            "train_type": "高铁"
          },
          {
            "id": "20230601G89101112",
            "start": "长沙南站",
            "destination": "北京西站",
            "createTime":'2022-10-10 17:46',
            "endTime":'2022-10-10 20:24',
            "train_number": "G8910",
            "carriage_number": 4,
            "seat_number": 17,
            "seat_class": "商务座",
            "price": 1452,
            "start_latitude_longitude": [112.983, 28.156],
            "destination_latitude_longitude": [116.407, 39.904],
            "train_type": "高铁"
          }
        ]
      },
   
    ]
    
  }
})



//生成车票管理
Mock.mock('/getOrder',()=>{
  return {
    message: "获取车次列表成功",
    code: 1,
    data: oredrData.list
  }
})


//生成车票管理
Mock.mock('/getTicket',()=>{
  return {
    message: "获取车次列表成功",
    code: 1,
    data: ticketData.list
  }
})

//生成车次管理列表
Mock.mock("/getCarlist", () => {
  return {
    message: "获取车次列表成功",
    code: 1,
    data: data.data
    //   {
    //     id: 1,
    //     train: "G71",
    //     vehicle: "张三",
    //     all: 586,
    //     carriage: 8,
    //     num: 646,
    //     date: new Date().getTime(),
    //     status: 1,
    //   },
    ,
  };
});

//生成车站管理列表
Mock.mock('/getStation',()=>{
  return {
    message: "获取车次列表成功",
    code: 1,
    data: stationData.list
  }
})
//生成线路列表
Mock.mock('/getLine',()=>{
  return {
    message: "获取车次列表成功",
    code: 1,
    data: lineData.list
  }
})



